package com.hairline.controller;


import com.hairline.bean.Topic;
import com.hairline.bean.vo.BaseRespVo;
import com.hairline.bean.vo.ListVo;
import com.hairline.bean.vo.WxListVo;
import com.hairline.bean.vo.WxTopicVo;
import com.hairline.service.WxTopicServices;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@RestController()
@RequestMapping("wx/topic")
public class WxTopicController {
    @Autowired
    WxTopicServices wxTopicServices;

    @RequestMapping("list")
    public BaseRespVo getTopicList(Integer page,Integer size){
        WxListVo vo=wxTopicServices.getTopicList( page, size);
        return BaseRespVo.ok(vo);
    }
    @RequestMapping("detail")
    public BaseRespVo getTopicDetail(Integer id){
        WxTopicVo topicVo = wxTopicServices.getTopicDetailById(id);
        String[] goods = topicVo.getGoods();

        HashMap<String, Object> mapVo = new HashMap<>();
        mapVo.put("topic",topicVo);
        mapVo.put("goods",goods);

        return BaseRespVo.ok(mapVo);
}

    @RequestMapping("related")
    public BaseRespVo getTopicRelated( Integer id){
        List<Topic> topicRelated = wxTopicServices.getTopicRelated(id);

        return BaseRespVo.ok(topicRelated);
    }

}
